import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:wangziyi/widget/toast.dart';

import 'product_details_state.dart';

class ProductDetailsLogic extends GetxController {
  final state = ProductDetailsState();

 List<Chip> chipItem(index){
        if(state.chips!=null){
          state.chips.clear();
          if(state.itemTitle[index]=='颜色'){
            state.color.forEach((element) {
              state.chips.add(Chip(label: Text(element)));
            });
          }else if(state.itemTitle[index]=='尺码')
          {
            state.size.forEach((element) {
              state.chips.add(Chip(label: Text(element)));
            });
          }
        }

    return  state.chips;
  }
  //减去商品数量
 void numberDetele() {
   if(state.minNumber.value<=1){
     state.minNumber.value=1;
     Mytoast('最少购买一件哦！');
   }else{
     state.minNumber.value--;
   }


  }
  //添加商品数量
 void numberAdd() {
   if(state.minNumber.value>200){
     state.minNumber.value=200;
   }else{
     state.minNumber.value++;
   }


 }

}
